#include <stdio.h>
void reverse(int* arr, int i, int e)
{
	
	while(i < e)
	{
		int temp = arr[i];
		arr[i] = arr[e];
		arr[e] = temp;
		i++;
		e--;
	}
}

int* rotate(int* nums, int numsSize, int k) 
{
	k %= numsSize;
	reverse(nums, 0, numsSize - k - 1);
	reverse(nums, numsSize-k, numsSize - 1);
	reverse(nums, 0, numsSize - 1);
	return nums;
}


int main()
{
	int arr[10] = { 1, 2, 3,4, 5, 6,7,8,9,10 };
	int* ret = rotate(arr, 10, 3);
	for (int i = 0; i < 10; i++)
	{
		printf("%d ", *(ret+i));
	}
	return 0;
}